<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<link rel="stylesheet" href="css/background.css">
<script type="text/javascript" src="jq/jquery-3.7.1.js"></script>
<body>
<form action="FenYeUserServlet" method="get" id="forms">

 <div id="right_div">
		           序号<input type="text" name="userId" id="userId">
		          用户名<input type="text" name="userName" id="userName">
		          密码<input type="text" name="userPass" id="userPass">
		          地址<input type="text" name="position" id="position">
		          电话<input type="text" name="phone" id="phone">
		          状态<input type="text" name="state" id="state">

            <input type="button" value="搜索" id="enterSouShuo">
            <input type="button" value="添加用户" id="addUser"" >
            <table id="showTable">
            	<tr>
 				<td>id</td>
 				<td>用户名</td>
 				<td>密码</td>
 				<td>电话</td>
 				<td>地址</td>
 				<td>状态</td>
 				<td>操作1</td>
 				<td>操作2</td>
 				</tr>
            
            <c:forEach items="${PageBean.data }" var="ss" varStatus="status">
 				<tr id='showUser'>
 				<td id='userId'>${ss.userId}</td>
 				<td id='userName'>${ss.userName}</td>
 				<td id='userPass'>${ss.userPass}</td>
 				<td id='phone'>${ss.phone}</td>
 				<td id='position'>${ss.position}</td>
 				<td id='state'>${ss.state}</td>
 				<td><a href="UserDeleteServlet?userId=${ss.userId }&tableName=users&tableId=userId">删除</a></td>
 				<td><a href='userUpdate.jsp?id=${ss.userId }&username=${ss.userName }&userpass=${ss.userPass}&phone=${ss.phone }&position=${ss.position }&state=${ss.state}'>修改</a></td>
 				</tr>
 				</c:forEach>
            </table>
            <h2>
				<a href="FenYeUserServlet?currentPageNum=1&&pageSize=5">第一页</a>
				<a href="FenYeUserServlet?currentPageNum=${PageBean.currentPageNum-1 }&&pageSize=5">上一页</a>
				<a href="FenYeUserServlet?currentPageNum=${PageBean.currentPageNum+1 }&&pageSize=5">下一页</a>
				<a href="FenYeUserServlet?currentPageNum=${PageBean.pageNum }&&pageSize=5">最后一页</a>
			</h2>
			<br><br>
			<h2>
				总页码${PageBean.pageNum }页， 当前第${PageBean.currentPageNum }页，总共有${PageBean.count }条记录
			</h2>
        </div>
        </form>
</body>
<script type="text/javascript">
		$("#enterSouShuo").click(function(){
			var  url=$("#forms");
			url[0].action="selectByUserServlet";
			console.log(url[0].action);
			$("#forms").submit();
		});
		
		$("#addUser").click(function(){
			console.log($("input[name=userName]").val())
				if($("input[name=userName]").val()==""){
					alert("用户名未填写！！！");
				}
				else if($("input[name=userPass]").val()==""){
					alert("密码未填写！！！");
				}
				else if($("input[name=position]").val()==""){
					alert("地址未填写！！！");
				}
				else if($("input[name=phone]").val()==""){
					alert("电话未填写！！！");
				}
				else if($("input[name=state]").val()==""){
					alert("状态未填写！！！");
				}else{
					var  url=$("#forms");
					url[0].action="addUserServlet";
					$("#forms").submit();
				}
		});

</script>
</html>